<!--
  模块：一键求助 - 分配部门 - 分配
-->
<template>
  <div class="help-assign-add" style="overflow:scroll;height:100%">

      <!-- 头部 -->
      <div class="header">
          <el-button type="primary" @click="Distributiondepartment">确认分配</el-button>
      </div>

      <!-- 内容 -->
      <div class="content">
          <el-row :gutter="20">
          <el-form label-position="top" :model="formParams" >
            <el-col :span="12" class="contents">
              <div class="left">

                  <CardFormTitle title="企业信息"></CardFormTitle>

                  <CardFormContent>

                    <el-form-item prop="companyName" label="企业名称">
                        <el-input
                            v-model="formParams.companyName"
                            clearable
                            disabled
                          />
                    </el-form-item>

                  <el-col :span="12">
                    <el-form-item prop="companyName" label="社会信用代码">
                        <el-input
                            v-model="formParams.creditCode"
                            clearable
                            disabled
                          />
                    </el-form-item>
                  </el-col>

                  <el-col :span="12">
                    <el-form-item prop="companyName" label="企业分类">
                        <el-input
                            v-model="formParams.companyType.desc"
                            clearable
                            disabled
                          />
                    </el-form-item>
                  </el-col>
                  </CardFormContent>

                  <div>
                  <CardFormTitle title="问题述求"></CardFormTitle>
                  </div>

                  <CardFormContent>



                  <el-col :span="12">
                    <el-form-item prop="companyName" label="求助类型">
                        <el-input
                            v-model="formParams.helpType.desc"
                            clearable
                            disabled
                          />
                    </el-form-item>
                  </el-col>

                  <el-col :span="12">
                    <el-form-item prop="companyName" label="求助时间">
                        <el-input
                            v-model="formParams.helpTime"
                            clearable
                           disabled
                          />
                    </el-form-item>
                  </el-col>

                  <el-col :span="24">
                    <el-form-item prop="companyName" label="问题和述求描述">
                        <el-input
                            v-model="formParams.queDes"
                            clearable
                            disabled
                            type="textarea"
                            maxlength="1000"
                            show-word-limit
                          />
                    </el-form-item>
                  </el-col>
                  </CardFormContent>


              </div>
            </el-col>
            <el-col :span="12" class="contents">
              <div class="right" style="text-align:left">
                <CardFormTitle title="分配部门"></CardFormTitle>
                <div class="right-content">
                <CardFormContent>
                    <el-col :span="12">
                    <el-form-item prop="assignDeptOne" label="选择部门" >
                        <el-select
                            v-model="formParams.assignDeptId"
                            @change="valueassignDeptOne"
                            :disabled="dynamic_judge()"
                        >
                        <el-option
                                  v-for="dict in selectdept"
                                  :key="dict.id"
                                  :label="dict.name"
                                  :value="dict.id"
                            />
                        </el-select>
                    </el-form-item>
                    </el-col>

                    <el-col :span="12">
                    <el-form-item prop="assignDeptTwo" label="重新选择部门" v-if="dynamic_judge()">
                        <el-select
                              v-model="assigndataTwo"
                             @change="valueassignDeptTwo"
                        >
                        <el-option
                                  v-for="dict in selectdept"
                                  :key="dict.id"
                                  :label="dict.name"
                                  :value="dict.id"
                            />
                        </el-select>
                    </el-form-item>
                    </el-col>

                    <el-col :span="24" >
                      <el-form-item prop="companyName" label="退回原因" v-if="dynamic_judge()">

                        <el-input
                            v-model="formParams.examineOpinion"
                            clearable
                            disabled
                            type="textarea"
                            maxlength="1000"
                            show-word-limit
                            style="resize:none"
                          />

                    </el-form-item>
                  </el-col>
                    </CardFormContent>
                </div>
                <CardFormTitle title="反馈信息"></CardFormTitle>
              </div>
            </el-col>
          </el-form>
          </el-row>

          <el-dialog
            title="处理结果"
            :visible.sync="dialogVisible"
            width="30%"
            :before-close="redirect"
            >
            <span>处理成功</span>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="redirect">确 定</el-button>
            </span>
          </el-dialog>

      </div>






  </div>
</template>

<script>
   // 样式
  import CardFormContent from "@/components/card-form-content"
  // 样式
  import CardFormTitle from "@/components/card-form-title"
  // 详情数据请求
  import { detailsdata,updateAllotHelp } from '@/api/help/assign'

export default {
  name: 'HelpAssignAdd',

  components:{
    CardFormContent,CardFormTitle
  },
  data(){
      return {
      // 数据ID
      detectionid:undefined,

      // 详情信息
      formParams:{},

      // 部门数据
      selectdept:{},

      // 部门选择第二个
      assigndataTwo:undefined,

      // 部门选择
      assigndata:undefined,

      // 对话框
      dialogVisible:false,


      }
  },

  created(){
      this.details()
  },

  methods:{

       // 获取详情数据
      details(){

          detailsdata(this.$route.query.id).then((respone)=>{
              this.detectionid = respone.data.btHelpAssignDetailsVO.id

              this.formParams = { ...respone.data.btHelpAssignDetailsVO }

              this.selectdept = { ...respone.data.selectdept }


          })
      },

      // 动态分组判断
      dynamic_judge(){
            return (this.formParams.back.value == 1 )
        },

      // 分配部门
      Distributiondepartment(){

       let allocation = {
            // 主键ID
            id:'',
            // 分配人ID
            assignUserId:'',
            // 分配人姓名
            assignUserName:'',
            // 分配部门
            assignDeptId:''
          }

        allocation.id = this.detectionid;

        allocation.assignUserId = this.$store.getters.userInfo.roleId;

        allocation.assignUserName = this.$store.getters.userInfo.userName;

        allocation.assignDeptId = this.assigndata;

        (this.assigndata != "" && this.assigndata != undefined) ? updateAllotHelp(allocation).then((respone)=>{
            this.dialogVisible = true
        }) : this.$alert("部门内容不能为空")



      },

      // 去首页
      redirect(){
          this.$router.push({
            name:"HelpAssign"
          })
          window.location.reload()
      },


      // 部门选择 第一个
      valueassignDeptOne(){
          this.assigndata = this.formParams.assignDeptId
      },

       // 部门选择 第二个
      valueassignDeptTwo(){
          this.assigndata = this.assigndataTwo
      }

  }

}
</script>

<style lang="scss" scoped>
  .header{
    width: 100%;
    padding: 10px;
    padding-right: 20px;
    background-color: white;
    text-align: right;
  }


  .content {
    width: 100%;
    height: 700px;
    padding-top: 24px;
    padding-left: 48px;
    padding-right: 48px;

    & .contents{
    border:20px solid rgb(226, 232, 240);
    height: 623px;
    background-color: rgb(255, 255, 255);
    text-align: left;
  }

  }


  .left{
    text-align: left;
  }

  .card-form-title{
    margin-top: 40px;
    padding-left: 10px;

  }

  .card-form-content{
      height:165px;
      width: 60%;
      margin-left: 20px;
  }

  .right-content{
    height: 210px;
  }



</style>
